/*GameSplash - Thanh*/
boolean toogleColor = false;
//Image m_imgSplashBackground;
Image m_imgSplashZombie;
Image m_imgSplashHuman;
Sprite m_sprSplashHuman, m_sprSplashZombie;
int aiSeque[]={0,0,1,1,2,2,3,3,};

void UpdateSplash(int mode)
{
	if (mode == UpdateType.UPDATE)
	{
		// if (IsAnyKeyPressed())
		// {
			// SwitchState(GameState.MainMenu);
        // }
		if(IsKeyPressed( DK_NUM5 | DK_PAD_MIDDLE))
		SwitchState(GameState.MainMenu);
	}	
	if (mode == UpdateType.PAINT)
	{
		// bg color
		// s_g.setColor(0x45473D);
		// s_g.fillRect(0, 0, getWidth(), getHeight());
		// bg image
		// s_g.drawImage(m_imgSplashBackground, 0, 0, Graphics.TOP | Graphics.LEFT);
		//text
		if (m_imgOptionBG != null)
		{
			s_g.drawImage(m_imgOptionBG, 0, 0, Graphics.TOP|Graphics.LEFT);
		}
		toogleColor = !toogleColor;
		// if (toogleColor) s_g.setColor(0xF7FF00); else s_g.setColor(0x0062FE);
		// s_g.setFont(Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_BOLD, Font.SIZE_LARGE));
		//s_g.drawString("PRESS KEY 5 TO CONTINUE.", 45, 156, s_g.TOP|s_g.LEFT);
		if(toogleColor)fonts[1].drawString("PRESS KEY 5 TO CONTINUE.",SCREEN_W>>1,SCREEN_H>>1,Graphics.HCENTER,s_g);
		else fonts[2].drawString("PRESS KEY 5 TO CONTINUE.",SCREEN_W>>1,SCREEN_H>>1,Graphics.HCENTER,s_g);
		//draw sprites
		//s_g.drawImage(m_imgSplashHuman, 0, 0, Graphics.TOP | Graphics.LEFT);
		m_sprSplashHuman.paint(s_g);
		m_sprSplashZombie.paint(s_g);
		m_sprSplashHuman.nextFrame();		
		m_sprSplashZombie.nextFrame();			
	
	}
	
	if (mode == UpdateType.CTOR)
	{   s_keyPressed=0;
		// play bg music if sound on
		// if (hasSound)
		// try	{
				// Player player = Manager.createPlayer(getClass().getResourceAsStream("/bgMusic.mid"),"audio/midi");
				// Player player = Manager.createPlayer(getClass().getResourceAsStream("/child.wav"),"audio/x-wav");
				// player.realize();
				// player.prefetch();
				// player.start();
			// }
			// catch(Exception e) {
				// System.out.println("Error Splash Music/sound:  ");
				// e.printStackTrace();
		// }
		// draw bg image
		PlaySound("/bgMusic.mid",2);
		try
		{ 
			// m_imgSplashBackground = Image.createImage("/Splash.jpg");
			m_imgSplashZombie = Image.createImage("/Splash_zombie_strip5.png");			
			m_imgSplashHuman = Image.createImage("/Splash_human_strip5.png");//180x50
            m_imgOptionBG = Image.createImage("/bg_pink_02.png");			
		}
		catch (Exception e)
		{
			System.out.println("Error in Splash_CTOR_Loanding_Image:  " + e.getMessage());
		}
			m_sprSplashHuman = new Sprite(m_imgSplashHuman, 36, 50);				
			m_sprSplashZombie = new Sprite(m_imgSplashZombie, 37, 45);
			m_sprSplashHuman.setPosition(145, 200);
			m_sprSplashZombie.setPosition(45, 200);	
			m_sprSplashHuman.setFrameSequence(aiSeque);
			m_sprSplashZombie.setFrameSequence(aiSeque);
	}
	if(mode == UpdateType.DTOR)
	{	
		// m_imgSplashBackground=null;
		m_imgSplashZombie=null;
		m_imgSplashHuman=null;
		m_sprSplashHuman=null;
		m_sprSplashZombie=null;
		m_imgOptionBG=null;
		aiSeque=null;
		System.gc();
	}	
}
